home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-09-27 | 2.0 KB | 93 lines | [TEXT/CWIE] |
- // included in ooftest2, 3 & 4
-
- REF_TABLE(dbPeople)
- SET_TABLE(dbVisits)
-
- CLASS_TABLE(dbPeople)
- dbChar LastName, Othernames;
- dbVisitsSet Visits;
- dbLong PatientNo;
- dbLong Salary;
-
- dbPeople() :
- dbTable("People"),
- LastName(40, "Last Name", kIndexed),
- Othernames(80, "Other names", kIndexed),
- PatientNo("PatientNo", kIndexNoDups),
- Salary("Salary", kIndexed)
- {};
-
- // my own data entry procedures
- void Add(const char *lname, const char *oname, const long salary);
- void AddVisit(const char* visitDate, const char* why);
- void AddTest2Data();
-
- };
-
-
- CLASS_TABLE(dbVisits)
- dbPeopleRef Person;
- dbLong PatientNo;
- dbDate VisitDate;
- dbText Why;
- dbVisits() :
- dbTable("Visits"),
- PatientNo("PatientNo", kIndexed),
- VisitDate("VisitDate", kIndexed),
- Why("Reason for Visit")
- {};
- };
-
-
- void dbPeople::Add(const char *lname, const char *oname, const long salary)
- {
- newRecord();
- LastName = lname;
- Othernames = oname;
- Salary = salary;
- PatientNo = sequenceNumber();
- saveRecord();
- }
-
-
- void dbPeople::AddVisit(const char* visitDate, const char* why)
- {
- Visits.newRecord();
- Visits->VisitDate() = visitDate;
- Visits->Why() = why;
- }
-
-
- void dbPeople::AddTest2Data()
- {
- // yes, if using SmartHeap debugging the following can take long enough to make folks wonder
- // there are a *lot* of places where OOFILE calls SmartHeap to check memory
- cout << "Generating new test records..." << flush;
- Add("Smith", "John", 20000);
- AddVisit("1/10/1994", "Sore Knee");
- AddVisit("14/10/1994", "Measles");
- saveRecord();
-
- Add("DENT", "Trissa", 99999);
- AddVisit("23-11-1994", "Flu");
- saveRecord();
-
- Add("Dent", "Andy", 50000);
- AddVisit("4.10.1994", "Flu");
- saveRecord();
-
- Add("Taylor", "Ken", 75000);
- cout << endl << endl;
- }
-
-
- // global variables that define the database using the above classes
-
- dbConnect_ctree theDB;
- dbPeople People;
- dbVisits Visits;
-
- dbRelationship PatientVisits(People.Visits, Visits.Person,
- People.PatientNo, Visits.PatientNo);
-
-